package com.jiangsong.mapper;

import com.jiangsong.entity.Product;
import com.jiangsong.service.dto.QueryProductInput;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author jiangsong
 * @date 2021/4/15
 **/

@Mapper
public interface ProductMapper {


    @Select("select * from product where acc_no = #{accNo}")
    List<Product> getProductByAccNo(String accNo);

    @Select("select count(id) as count from product")
    int count();

    /**
     * 批量插入数据
     */
    @Insert("insert into product (acc_no, vendi_no, begin_date, end_date) values(#{product.accNo},#{product.vendiNo},#{product.beginDate}, #{product.endDate})")
    int insertOne(@Param("product") Product product);

    @Select("select * from product where valid_flag = #{input.validFlag} limit #{input.pageSize} offset #{input.startIndex}")
    List<Product> getProductByPage(@Param("input") QueryProductInput queryProductInput);

    @Select("select count(*) from product where valid_flag = #{input.validFlag} ")
    Integer getCount(@Param("input") QueryProductInput queryProductInput);


}
